package com.softer.chengxin.project.controller;

import com.softer.chengxin.common.domin.CommonResult;
import com.softer.chengxin.common.domin.ManagerPageResult;
import com.softer.chengxin.common.domin.Page;
import com.softer.chengxin.project.domin.Housing;
import com.softer.chengxin.project.service.HousingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Gong Zhiyang
 * @date 2018/10/16
 */
@RestController
@RequestMapping("/api/housing")
public class HousingController {
    @Autowired
    private HousingService housingService;

    /**
     * 新增物业用房信息
     *
     * @param housing 物业用房信息
     * @return 结果
     */
    @PostMapping("/add")
    public CommonResult add(Housing housing) {
        return housingService.add(housing);
    }

    /**
     * 查询项目物业用房列表
     *
     * @param page    页面实体
     * @param housing 查询实体
     *                projectId   项目ID
     *                roomAddress 物业用房地址
     *                roomNature  物业用房性质
     * @return 列表
     */
    @PostMapping("/queryHousingList")
    public ManagerPageResult queryHousingList(Page page, Housing housing) {
        return housingService.queryHousingList(page, housing);
    }

    /**
     * 删除物业用房信息
     *
     * @param id 物业用房Id
     * @return 结果
     */
    @PostMapping("/delete")
    public CommonResult delete(Integer id) {
        return housingService.delete(id);
    }

    /**
     * 查看物业用房信息
     *
     * @param id 物业用房ID
     * @return 信息
     */
    @PostMapping("/detail")
    public Housing detail(Integer id) {
        return housingService.detail(id);
    }

    /**
     * 编辑物业用房信息
     *
     * @param housing 用房信息
     * @return 结果
     */
    @PostMapping("/edit")
    public CommonResult edit(Housing housing) {
        return housingService.edit(housing);
    }
}
